package dms.service.imp;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import dms.model.Building;
import dms.model.Dormitory;
import dms.model.form.Repair;
import dms.model.util.PageIterator;
import dms.repository.RepairRepository;
import dms.service.RepairQueryService;

public class RepairQueryServiceImpl implements RepairQueryService {
	
	private static final Log log = LogFactory.getLog(RepairQueryServiceImpl.class);
	
	private RepairRepository repairRepository = null;

	/**
	 * @return the repairRepository
	 */
	public RepairRepository getRepairRepository() {
		return repairRepository;
	}

	/**
	 * @param repairRepository the repairRepository to set
	 */
	public void setRepairRepository(RepairRepository repairRepository) {
		this.repairRepository = repairRepository;
	}

	@Override
	public PageIterator<Repair> findByBuilding(int start, int count,
			Building building) {
		return this.repairRepository.findByBuilding(start, count, null, null, building);
	}

	@Override
	public PageIterator<Repair> findByBuildingAndDate(int start, int count,
			Date fromDate, Date toDate, Building building) {
		return this.repairRepository.findByBuilding(start, count, fromDate, toDate, building);
	}

	@Override
	public PageIterator<Repair> findByBuildingAndProcessed(int start,
			int count, Building building, Date fromDate, Date toDate, Boolean processed,
			Boolean applied) {
		return this.repairRepository.findByBuilding(start, count, fromDate, toDate, building, processed, applied);
	}

	@Override
	public PageIterator<Repair> findByBuildingAndProcessed(int start,
			int count, Building building, Boolean processed, Boolean applied) {
		return this.repairRepository.findByBuilding(start, count, null, null, building, processed, applied);
	}

	@Override
	public PageIterator<Repair> findByDormitory(int start, int count,
			Dormitory dormitory) {
		return this.repairRepository.findByDormitory(start, count, null, null, dormitory);
	}

	@Override
	public PageIterator<Repair> findByDormitoryAndDate(int start, int count,
			Date fromDate, Date toDate, Dormitory dormitory) {
		return this.repairRepository.findByDormitory(start, count, fromDate, toDate, dormitory);
	}

	@Override
	public Repair findRepairById(Long id) {
		return this.repairRepository.findById(id);
	}

	/**
	 * @param repairRepository
	 */
	public RepairQueryServiceImpl(RepairRepository repairRepository) {
		super();
		this.repairRepository = repairRepository;
	}

	/**
	 * 
	 */
	public RepairQueryServiceImpl() {
		super();
	}

}
